﻿using System;

namespace UFrame
{
    public class IntToIntConverter
    {
        
        public int[] indexAry;

        public IntToIntConverter()
        {
            
        }

        public IntToIntConverter(int [] indexAry)
        {
            this.indexAry = indexAry;
        }

        public object Convert(object value)
        {
            int b = (int)value;
            for (int i = 0; i < indexAry.Length; i++)
            {
                if (indexAry[i] == b)
                {
                    return indexAry[i];
                }
            }
            return indexAry[0];
        }

        public object ConvertBack(object value)
        {
            int b = (int)value;
            for (int i = 0; i < indexAry.Length; i++)
            {
                if (indexAry[i] == b)
                {
                    return i;
                }
            }
            return 0;
        }
    }
}